###########################################################
# Kerice Doten-Snitker
# 
# Prepared for:
# Doten-Snitker, K. 2021. "Contexts of State Violence: Jewish Expulsions in the Holy Roman Empire." Social Science History 45(1):131-163. https://doi.org/10.1017/ssh.2020.39
# 
# Built under R 3.4.3 
# Platform: x86_64-apple-darwin15.6.0 (64-bit)
###########################################################

# # set locale to preempt UTF-8 issues with the mydata
# Sys.getlocale()
# # for Mac
# Sys.setlocale(category = "LC_ALL", locale = "en_US.UTF-8")
# #for windows
# #Sys.setlocale(category = "LC_ALL", locale = "English_United States.1252")
# 
# # add packages with the pacman library, which installs if not installed
# library(pacman)
# # use the here package for improving replicability
# p_load(here)
# # for data manipulation
# p_load(magrittr, plyr, tidyverse, reshape2)
# 
# set.seed(1418)

###
# Observations are city-years in which a pogrom occurred
# with pogrom classifications
###

# add the pogrom data to the R environment 
mydata_pm <- read.csv(here::here("in_data","Haverkamp_Ortskatalog_limited_pogroms.csv"), 
  header=TRUE, encoding = "latin1", stringsAsFactors=FALSE)

# 1: Recoding and new variables --------------------------------------------

mydata_pm <- mydata_pm %>%
  mutate(
    Vfg = 1, # all obs had a persecution - set up for binary after merge
    VfgRmord = ifelse(VfgType==1,1,0), # Ritualmord/ritual murder
    VfgHost = ifelse(VfgType==2,1,0), # Hostienfrevel/host desecration
    VfgGeld = ifelse(VfgType==3,1,0), # Gelderpressung/extortion
    VfgCrusade = ifelse(VfgType==4,1,0), # Crusades
    VfgRint = ifelse(VfgType==5,1,0), # Rintfleisch
    VfgWerner = ifelse(VfgType==6,1,0), # Guter Werner
    VfgArm = ifelse(VfgType==7,1,0), # Armleder
    VfgPest = ifelse(VfgType==8,1,0), # Pest/Plague
    VfgSchwz = ifelse(VfgType==9,1,0), # Schweizer Söldner/Swiss soldiers
    VfgOther = ifelse(VfgType==10,1,0) # other local
  )
